﻿/************************************************************************************
 * 漠然(459699936@qq.com) 2014/12/28 6:59:11
 ************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;

namespace JsonRpc
{
    /// <summary>
    /// 将.addin文件解析出来
    /// </summary>
    class BundleXmlConfigLoader
    {
        XDocument doc;

        public BundleXmlConfigLoader(string filePath) {
            doc = XDocument.Load(filePath);
        }

        public void Walk() {
            var root = doc.Root;
            walk(root);
        }

        private void walk(XElement root) {
            Console.WriteLine(root.Name);
            if (root.HasAttributes) {
                foreach (var att in root.Attributes()) {
                    Console.WriteLine("{0}={1}", att.Name, att.Value);
                }
            }

            Console.WriteLine("\r\n");
            foreach (var node in root.Elements()) {
                walk(node);
            }
        }

    }
}
